<!DOCTYPE HTML>
<html lang="cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
  <%include("/common/header.html",{title:''}){}%>
  <title>操作记录</title>
  <style>
  </style>
</head>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=IENn7ABARjQIkTeAKyh80VTkg2jYXf3K"></script>
<body>


<div class="x-nav" style="margin: 20px auto auto 15px;">
      <span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
        <a href="javascript:;">首页</a><span lay-separator="">/</span>
        <a href="javascript:;">系统设置</a><span lay-separator="">/</span>
        <a><cite>操作记录</cite></a>
      </span>
  <a class="layui-btn layui-btn-primary layui-btn-small" style="margin: -5px 14px 0px 0px;float:right;"
     href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon layui-icon-refresh-3"></i>
  </a>
</div>


<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label">操作日期</label>
          <div class="layui-input-block">
            <input type="text" name="goodsName" placeholder="请输入操作日期..."
                   autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">操作人</label>
          <div class="layui-input-block">
            <select type="text" name="classify" id="f_classify11" autocomplete="off" class="layui-select">
            </select>
          </div>
        </div>


        <div class="layui-inline">
          <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
          </button>
        </div>
      </div>
    </div>


    <div class="layui-card-body">
      <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
      <script type="text/html" id="toolbarDemo">
        <button class="layui-btn layuiadmin-btn-useradmin">商品服务信息</button>
      </script>
      <!--<script type="text/html" id="table-useradmin-webuser">
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
      </script>-->
      <script type="text/html" id="table-useradmin-webuser">
        <a id="refuse" class="layui-btn layui-bg-red layui-btn-xs" lay-event="refuse"><i
                class="layui-icon layui-icon-close-fill"></i>删除</a>
      </script>
    </div>
  </div>
</div>
<!-- 弹出修改页面 -->
<div class="layui-form" lay-filter="layuiadmin-form-useradmin"
     id="layuiadmin-form-useradmin"
     style="padding: 15px;display: none">
  <form action class="layui-form" lay-filter="component-form-element" id="myform">
    <input type="hidden" name="id">
    <input type="hidden" name="account">
    <input type="hidden" name="img" id="img123">

    <div class="layui-form-item" id="reason">
      <label class="layui-form-label"
             style="color:red;padding-left: 0px;font-size: medium;width: auto;">拒绝原因:</label>
      <div class="layui-input-inline" style="width: 600px">
        <textarea disabled type="text" name="" id="reason11" style="width: 400px;height: 100px;"></textarea>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务者:</label>
      <div class="layui-input-inline">
        <input type="text" disabled name="techName" lay-verify="required" value="" class="layui-input"
               placeholder="">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务名称:</label>
      <div class="layui-input-inline">
        <input type="text" name="goodsName" lay-verify="required" value="" class="layui-input"
               placeholder="请输入服务名称">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务介绍:</label>
      <div class="layui-input-inline" style="width: 555px">
                <textarea id="introduce" type="text" style="display: none" name="describe"
                          lay-verify="content"></textarea>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务价格:</label>
      <div class="layui-input-inline">
        <input style="float:left;width: 140px;" type="text" name="price" lay-verify="required" value=""
               class="layui-input"
               placeholder="请输入服务价格"><span style="position: absolute;top: 10px;left: 144px;">元/次</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务时长:</label>
      <div class="layui-input-inline">
        <input style="float:left;width: 140px;" type="text" name="time" lay-verify="required" value=""
               class="layui-input"
               placeholder="请输入服务时长"><span style="position: absolute;top: 10px;left: 144px;">分钟/次</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务父分类:</label>
      <div class="layui-input-inline">
        <select lay-filter="f_classify" style="height: 40px;width: 70px" lay-verify="required" id="classifys"
                name="classify">
        </select>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">专长子分类:</label>
      <div class="layui-input-inline">
        <select style="height: 40px;width: 70px" lay-verify="required" id="s_classify" name="s_classify">
        </select>
      </div>
    </div>

    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师名称:</label>-->
    <!--<div class="layui-input-inline">-->
    <!--<input type="text" name="seniority" lay-verify="required" value="" class="layui-input"-->
    <!--placeholder="请输入技师名称">-->
    <!--</div>-->
    <!--</div>-->

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师性别:</label>
      <div class="layui-input-inline">
        <input checked type="radio" name="sex" lay-verify="required" value="男" class="layui-radio"
               placeholder="请选择技师性别"><span style="position: absolute;left: 27px;top: 10px;">男</span>
        <input type="radio" name="sex" lay-verify="required" value="女" class="layui-radio"
               placeholder="请选择技师性别"><span style="position: absolute;left: 80px;top: 10px;">女</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师年龄:</label>
      <div class="layui-input-inline">
        <input style="float:left;width: 140px;" type="text" name="age" lay-verify="required" value=""
               class="layui-input"
               placeholder="请输入技师年龄"><span style="position: absolute;top: 10px;left: 144px;">周岁</span>
      </div>
    </div>

    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师资质:</label>-->
    <!--<div class="layui-input-inline">-->
    <!--<input type="text" name="seniority" lay-verify="required" value="" class="layui-input"-->
    <!--placeholder="请输入技师资质">-->
    <!--</div>-->
    <!--</div>-->

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">工作年限:</label>
      <div class="layui-input-inline">
        <input style="float:left;width: 140px;" type="text" name="year" lay-verify="required" value=""
               class="layui-input"
               placeholder="请输入工作年限"><span style="position: absolute;top: 10px;left: 144px;">年</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">联系电话:</label>
      <div class="layui-input-inline">
        <input type="text" name="tel" lay-verify="required" value="" class="layui-input"
               placeholder="请输入联系电话">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">商家地址:</label>
      <div class="layui-input-inline">
        <input type="text" id="secadds" name="secadds" value="" class="layui-input"
               placeholder="商家地址查询">
      </div>
      <button class="layui-btn" id="mypsec" type="button">搜索</button>
    </div>
    <div id="allmap" style="width: 400px;height: 400px;"></div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">经度:</label>
      <div class="layui-input-inline">
        <input type="text" id="lng" name="lng" lay-verify="required" value="" class="layui-input"
               placeholder="经度" readonly>

      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">纬度:</label>
      <div class="layui-input-inline">
        <input type="text" id="lat" name="lat" lay-verify="required" value="" class="layui-input"
               placeholder="纬度" readonly>

      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">详细地址:</label>
      <div class="layui-input-inline">
        <input type="text" name="address" lay-verify="required" value="" class="layui-input"
               placeholder="请输入详细地址">

      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师资质:</label>
      <div id="layer-photos-demo1" class="layer-photos-demo">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">封面图片:</label>
      <div id="layer-photos-demos" class="layer-photos-demo">
        <img class="layui-upload-img" width="200px" height="200px" id="img1"/>
      </div>
    </div>
    <!--  <div class="layui-form-item">
        <div class="layui-inline">
          <div class="layui-input-inline">
            <button type="button" class="layui-btn" id="upload1">上传封面图</button>
            <div class="layui-upload-list">
              <img class="layui-upload-img" width="100px" height="80px" id="img1"/>
              <p id="demoText"></p>
            </div>
          </div>
        </div>
      </div>-->
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">轮播图片:</label>
      <div id="layer-photos-demo" class="layer-photos-demo">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务图片:</label>
      <div id="layer-photos-service" class="layer-photos-demo">
      </div>
    </div>

    <div class="layui-form-item">
      <div class="layui-input-block" style="margin-left: 240px;">
        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">立即提交</button>
      </div>
    </div>
  </form>
</div>
<script id="demo" type="text/html">
  <option value="">请选择</option>
  {{#  layui.each(d.list, function(index, item){ }}

  <option {{d.classify== item.id?"selected":""}} value="{{ item.id }}">{{ item.name }}</option>

  {{#  }); }}
  {{#  if(d.list.length === 0){ }}
  无数据
  {{#  } }}
</script>
<script id="demo2" type="text/html">
  <!--<option value="">请选择</option>-->
  {{#  layui.each(d.list2, function(index, item2){ }}

  <option {{d.s_classify== item2.name?"selected":""}} value="{{ item2.name }}">{{ item2.name }}</option>

  {{#  }); }}
  {{#  if(d.list2.length === 0){ }}
  <option disabled value="">无</option>
  {{#  } }}
</script>
<script id="demo4" type="text/html">
  <option value="">请选择</option>
  {{#  layui.each(d.list4, function(index, item4){ }}

  <option value="{{ item4.id }}">{{ item4.name }}</option>

  {{#  }); }}
  {{#  if(d.list4.length === 0){ }}
  无数据
  {{#  } }}
</script>
<!-- 弹出查看页面 -->
<div class="layui-form" lay-filter="layuiadmin-form-useradmin"
     id="layuiadmin-form-useradmin1"
     style="padding: 15px;display: none">
  <form action class="layui-form" lay-filter="component-form-element1" id="myform1">

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">平台服务费:</label>
      <div class="layui-input-inline">
        <input type="text" id="charge1" name="charge1" disabled class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务者:</label>
      <div class="layui-input-inline">
        <input type="text" id="techName1" name="techName" disabled class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务名称:</label>
      <div class="layui-input-inline">
        <input type="text" id="goodsName1" name="goodsName" disabled class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务介绍:</label>
      <div class="layui-input-inline" style="width: 555px">
        <textarea disabled class="layui-textarea" type="text" id="introduce1" name="describe"></textarea>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务价格:</label>
      <div class="layui-input-inline">
        <input disabled style="float:left;width: 140px;" type="text" id="price1" name="price"
               class="layui-input"><span
              style="position: absolute;top: 10px;left: 144px;">元/次</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务时长:</label>
      <div class="layui-input-inline">
        <input disabled style="float:left;width: 140px;" type="text" id="time1" name="time" class="layui-input"><span
              style="position: absolute;top: 10px;left: 144px;">分钟/次</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务分类:</label>
      <div class="layui-input-inline">
        <input type="text" id="classify1" name="classify" disabled class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务子分类:</label>
      <div class="layui-input-inline">
        <input type="text" id="s_classify1" name="s_classify" disabled class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师性别:</label>
      <div class="layui-input-inline">
        <input disabled checked type="radio" value="男" name="sex" class="layui-radio"><span
              style="position: absolute;left: 27px;top: 10px;">男</span>
        <input disabled type="radio" name="sex" value="女" lay-verify="required" class="layui-radio"><span
              style="position: absolute;left: 80px;top: 10px;">女</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师年龄:</label>
      <div class="layui-input-inline">
        <input disabled style="float:left;width: 140px;" type="text" id="age1" name="age"
               class="layui-input"><span
              style="position: absolute;top: 10px;left: 144px;">周岁</span>
      </div>
    </div>

    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师资质:</label>-->
    <!--<div class="layui-input-inline">-->
    <!--<input disabled type="text" id="seniority1" name="seniority" class="layui-input">-->
    <!--</div>-->
    <!--</div>-->

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">工作年限:</label>
      <div class="layui-input-inline">
        <input disabled style="float:left;width: 140px;" type="text" id="year1" name="year" class="layui-input"><span
              style="position: absolute;top: 10px;left: 144px;">年</span>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">联系电话:</label>
      <div class="layui-input-inline">
        <input disabled type="text" id="tel1" name="tel" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">详细地址:</label>
      <div class="layui-input-inline">
        <input disabled type="text" id="address1" name="address" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">技师资质:</label>
      <div id="seniority1" class="layer-photos-demo">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">封面图片:</label>
      <div id="fengmian" class="layer-photos-demo">
        <img class="layui-upload-img" width="200px" height="200px" id="img2"/>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">轮播图片:</label>
      <div id="xiangxi" class="layer-photos-demo">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label" style="padding-left: 0px;font-size: medium;width: auto;">服务图片:</label>
      <div id="service" class="layer-photos-demo">
      </div>
    </div>

    <!-- <div class="layui-form-item">
       <div class="layui-inline">
         <div class="layui-input-inline">
           <button type="button" class="layui-btn">封面图</button>
           <div class="layui-upload-list">
             <img class="layui-upload-img" width="100px" height="80px" id="img2"/>
             <p id="demoText1"></p>
           </div>
         </div>
       </div>
     </div>-->
  </form>
</div>
<%include("/common/foot.html"){}%>
<script>

  layui.use(['index', 'table', 'form', 'laydate', 'layedit', 'AjaxCommon', 'AliangLayui'], function () {
    var $ = layui.$;
    var table = layui.table;
    var form = layui.form;
    var laydate = layui.laydate;
    var AjaxCommon = layui.AjaxCommon;
    var AliangLayui = layui.AliangLayui;

    var title = "修改商品服务";
    var findAll_url = 'system/goods/findAll.json';
    var update_url = 'system/goods/update.json';
    var agree_url = 'system/goods/agree.json';
    var refuse_url = 'system/goods/refuse.json';
    var charge_url = 'system/goods/charge.json';
    var index;//定义建立富文本编辑器全局变量
    var layedit//定义富文本编辑器layedit全局变量
    var cols = [ //表头
      /*{checkbox: true, fixed: true},
      {
        field: 'createDate',
        width: "150",
        templet: "<div>{{layui.util.toDateString(d.createDate, 'yyyy-MM-dd ')}}</div>",
        title: '发布时间',
        fixed: 'left',
      },*/
      {field: 'operator', title: '操作人', sort: true},
      {field: 'operationfunction', title: '操作方法',},
      {field: 'operationcontent', title: '操作内容',},
      {field: 'addtime', title: '添加时间'},

      /*{
        field: 'image',
        width: "110",
        title: '轮播缩略图',
        templet: "<div><img src={{d.image}} style='width:30px;height:30px'></div>"
      },*/
      {title: '操作', fixed: 'right', width: 300, toolbar: '#table-useradmin-webuser',}
    ];
    AliangLayui.createTable(
      "#LAY-user-manage",
      "listReload",
      "#toolbarDemo",
      title,
      'DATA/操作记录.json',
      true,
      [10, 15, 20, 25],
      ['filter', 'print', 'exports'],
      cols,
      null
    );

    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom("沈阳", 12);
    map.enableScrollWheelZoom(true);
    var local = new BMap.LocalSearch(map, {
      renderOptions: {map: map}
    });
    //单击获取点击的经纬度
    map.addEventListener("click", function (e) {
      //alert(e.point.lng + "," + );
      $("#lng").val(e.point.lng);
      $("#lat").val(e.point.lat);
      layer.msg("更新位置成功", {
        icon: 6
      });

    });

    $("#mypsec").on('click', function () {
      local.search($("#secadds").val());
    });

    //搜索栏服务分类
    $.ajax({
      url: "system/classify/getF.json",
      type: "POST",
      data: {},
      dataType: "json",
      success: function (ret4) {
        var laytpl = layui.laytpl;
        var rets = { //数据
          "list4": ret4,
        };
        laytpl($("#demo4").html()).render(rets, function (html) {
          $("#f_classify11").html(html);
        });
        // $("#classifys").val(ret.name);
        form.render();

      },
      error: function (jqXHR, textStatus, errorThrown) {

      }
    });


    //监听搜索
    form.on('submit(LAY-user-front-search)', function (data) {
      var field = data.field;
      //执行重载
      table.reload('listReload', {
        where: {

          goodsName: field.goodsName,
          classify: field.classify

        },
        page: {
          curr: 1//重新从第 1 页开始
        }
      });
    });


    //初始化修改页面

    function loadData(data) {

      var ret = {
        "id": data.id,
        // "classify": data.classifys.name,
        "s_classify": data.s_classify,
        "goodsName": data.goodsName,
        "price": data.price,
        "introduce": data.introduce,
        "status": data.status,
        "time": data.time,
        "sex": data.sex,
        "age": data.age,
        "seniority": data.seniority,
        "year": data.year,
        "tel": data.tel,
        "address": data.address,
        "account": data.account,
        "charge": data.charge,
        "lng": data.lng,
        "lat": data.lat,
        "describe": data.describe,
        "img": data.img,
        "techName": data.techName,
      }
      var reason1 = data.reason1;
      if (reason1 == null || reason1 == "") {
        $("#reason").hide();
      } else {
        $("#reason").show();
        $("#reason11").val(reason1);
      }
      $("#img1").attr("src", data.img);
      $("#img123").val(data.img);
      $("#classifys").val(data.classifys.id);
      $("#introduce").val(data.introduce);
      $("#s_classify").append("<option value=" + data.s_classify + ">" + data.s_classify + "</option>");
      for (var i = 0; i < data.goodsImage.length; i++) {
        $("#layer-photos-demo").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.goodsImage[i].image + '" src="' + data.goodsImage[i].image + '" alt="' + data.goodsName + '">&nbsp;&nbsp;')
      }
      for (var i = 0; i < data.seniorityImages.length; i++) {
        $("#layer-photos-demo1").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.seniorityImages[i].image + '" src="' + data.seniorityImages[i].image + '" alt="' + data.goodsName + '">&nbsp;&nbsp;')
      }
      for (var i = 0; i < data.serviceImage.length; i++) {
        $("#layer-photos-service").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.serviceImage[i].image + '" src="' + data.serviceImage[i].image + '" alt="' + data.goodsName + '">&nbsp;&nbsp;')
      }
      form.render();
      layer.photos({
        photos: '#layer-photos-demos'
        , anim: 5
      });
      layer.photos({
        photos: '#layer-photos-demo'
        , anim: 5
      });
      layer.photos({
        photos: '#layer-photos-demo1'
        , anim: 5
      });
      return ret;
    }


    //图片上传
    AliangLayui.layuiImagepost("#upload1", "#img1");
    //初始化日期模块
    laydate.render({
      elem: '#createDate' //指定元素
    });
    //////////////////////////////////////以上是修改每个页面修改的地方
    //弹出修改页面调用初始化数据方法
    function initUpdate(data) {
      var a = layer.open({
        type: 1,
        title: title,
        content: $('#layuiadmin-form-useradmin'),
        btn: ['关闭'], //可以无限个按钮
        cancel: function (index, layero) {//取消事件
          location.replace(location.href);　//layer.open关闭刷新
        },
        success: function (layero, index) {
          layer.iframeAuto(index);
        }
      });
      layer.full(a);
      //服务分类
      $.ajax({
        url: "system/classify/getF.json",
        type: "POST",
        data: {},
        dataType: "json",
        success: function (ret) {
          var laytpl = layui.laytpl;
          var rets = { //数据
            "list": ret,
            classify: data.classify
          };
          laytpl($("#demo").html()).render(rets, function (html) {
            $("#classifys").html(html);
          });
          // $("#classifys").val(ret.name);
          form.render();

        },
        error: function (jqXHR, textStatus, errorThrown) {

        }
      });

      $.ajax({
        url: "system/classify/getS.json",
        type: "POST",
        data: {
          fid: data.classify
        },
        dataType: "json",
        success: function (ret) {
          var laytpl = layui.laytpl;
          var ret2 = { //数据
            "list2": ret,
            s_classify: data.s_classify
          };
          laytpl($("#demo2").html()).render(ret2, function (html) {
            $("#s_classify").html(html);
          });
          form.render();

        },
        error: function (jqXHR, textStatus, errorThrown) {

        }
      });
      //如果是添加则重置表单，如果是编辑则给表单赋值
      if (data == 0 || data == null) {
        $('#myform')[0].reset();
        return;
      } else {
        layui.form.val("component-form-element", loadData(data));
      }

      //富文本编辑器
      layedit = layui.layedit;
      //图片接口
      layedit.set({
        uploadImage: {
          url: 'system/block1/upimage.jhtml' //接口url
          , type: 'post' //默认post
        }
      });
      //建立编辑器
      index = layedit.build('introduce', {
        tool: ['strong', 'italic', 'underline', 'del', '|',
          'left', 'center', 'right', '|', 'link', 'unlink',],
        height: 280
      });
      //富文本赋值
      // layedit.setContent(index,data.introduce);
      //富文本表单验证
      form.verify({
        introduce: function (value) {
          var val = layedit.getText(index);
          //alert(val.length)
          if (val.length < 6) {

            return '内容至少6个字符'
          }
        }
      });

      //子分类联动
      form.on('select(f_classify)', function (data1) {
        var f_classify = data1.value;
        f_classify = f_classify.replace("\"", "").replace("\"", "");
        var f_classify = parseInt(f_classify);
        $.ajax({
          url: "system/classify/getS.json",
          type: "POST",
          data: {
            fid: f_classify
          },
          dataType: "json",
          success: function (ret) {
            var laytpl = layui.laytpl;
            var ret2 = { //数据
              "list2": ret,
              s_classify: data.s_classify
            };
            laytpl($("#demo2").html()).render(ret2, function (html) {
              $("#s_classify").html(html);
            });
            form.render();

          },
          error: function (jqXHR, textStatus, errorThrown) {

          }
        });
        $("#areaid").empty();
        //$("#qqq").show();
        //alert(JSON.stringify(data.value))
      });
    }


    //弹出查看页面调用初始化数据方法
    function initUpdate1(data) {
      var a = layer.open({
        type: 1,
        title: title,
        content: $('#layuiadmin-form-useradmin1'),
        btn: [], //可以无限个按钮
        cancel: function (index, layero) {//取消事件
          location.replace(location.href);　//layer.open关闭刷新
        },
        success: function (layero, index) {
          layer.iframeAuto(index);
        }
      });
      layer.full(a);
      //给表单赋值
      $("#classify1").val(data.classifys.name);
      $("#goodsName1").val(data.goodsName);
      $("#price1").val(data.price);
      $("#techName1").val(data.techName);
      // var introduce = data.introduce;
      // introduce = introduce.replace(/(\n)/g, "");
      // introduce = introduce.replace(/(\t)/g, "");
      // introduce = introduce.replace(/(\r)/g, "");
      // introduce = introduce.replace(/<\/?[^>]*>/g, "");
      // introduce = introduce.replace(/\s*/g, "");
      $("#introduce1").val(data.describe);
      $("#status1").val(data.status);
      $("#time1").val(data.time);
      $("#sex1").val(data.sex);
      $("#age1").val(data.age);
      $("#year1").val(data.year);
      $("#tel1").val(data.tel);
      $("#address1").val(data.address);
      $("#account1").val(data.account);
      $("#s_classify1").val(data.s_classify);
      $("#img2").attr("src", data.img);
      $("#charge1").val(data.charge);
      for (var i = 0; i < data.goodsImage.length; i++) {
        $("#xiangxi").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.goodsImage[i].image + '" src="' + data.goodsImage[i].image + '" alt="' + data.goodsName + '">&nbsp;&nbsp;')
      }
      for (var i = 0; i < data.seniorityImages.length; i++) {
        $("#seniority1").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.seniorityImages[i].image + '" src="' + data.seniorityImages[i].image + '" alt="' + data.seniorityImages + '">&nbsp;&nbsp;')
      }
      for (var i = 0; i < data.serviceImage.length; i++) {
        $("#service").append('<img style="width: 200px;height: 200px;" class="layui-upload-img"  layer-src="' + data.serviceImage[i].image + '" src="' + data.serviceImage[i].image + '" alt="' + data.serviceImage + '">&nbsp;&nbsp;')
      }
      //layui.form.val("component-form-element1", loadData(data));
      layer.photos({
        photos: '#fengmian'
        , anim: 5
      });
      layer.photos({
        photos: '#xiangxi'
        , anim: 5
      });
    }


    //修改页面的内容提交到后台处理
    form.on('submit(component-form-element)', function (data) {
      data.field.introduce = layedit.getContent(index);
      postUpdate(data);
      return false;
    });
    //头工具栏事件
    table.on('toolbar(LAY-user-manage)', function (obj) {
      var checkStatus = table.checkStatus(obj.config.id);
      switch (obj.event) {
        case 'add':
          initUpdate(0);
          break;
        case 'delete':
          var data = checkStatus.data;
          if (data.length > 0) {
            //var id = new Array(); //声明数组
            for (var i in data) {
              var a = data[i].id; //得到复选框的值
              postDelete(a);
            }
          } else {
            layer.msg("至少选择一个进行删除");
          }
          break;
        case 'export':
          layer.msg("导出");
          break;
      }
    });

    //点击每行右工具栏“操作”里面按钮效果
    table.on('tool(LAY-user-manage)', function (obj) {
      var data = obj.data;
      if (obj.event === 'agree') {
        layer.prompt({title: '请输入平台服务费', formType: 3}, function (text, index) {
          layer.close(index);
          text = text.replace(/[^\d^\.]+/g, '');
          var fee = parseFloat(text);
          var p = data.price;
          if (fee < p) {
            $.ajax({
              url: agree_url,
              type: "POST",
              data: {
                "id": data.id,
                "code": 0,
                "charge": text
              },
              dataType: "json",
              success: function (ret) {
                //alert(ret.code)
                layer.msg(ret.msg, {icon: 6});

                setTimeout(function () {

                  window.location.reload();
                }, 1000);

              },
              error: function (jqXHR, textStatus, errorThrown) {
                var estr = "Page:" + window.location.pathname + ",Function: postDelete()";
                layer.open({
                  title: "错误信息",
                  area: ['600px', '600px'],
                  type: 2,
                  content: "base/error.jhtml?info=" + estr, //
                  btn: ['关闭'] //可以无限个按钮
                });
              }
            });
          } else {
            layer.msg('平台服务费必须小于商品价格');
          }
        })
      } else if (obj.event === 'chargee') {
        layer.prompt({title: '请输入平台服务费', formType: 3, value: data.charge}, function (text, index) {
          layer.close(index);
          text = text.replace(/[^\d^\.]+/g, '');
          var fee = parseFloat(text);
          var p = data.price;
          if (fee < p) {
            $.ajax({
              url: charge_url,
              type: "POST",
              data: {
                "id": data.id,
                "charge": text
              },
              dataType: "json",
              success: function (ret) {
                //alert(ret.code)
                layer.msg(ret.msg, {icon: 6});

                setTimeout(function () {

                  window.location.reload();
                }, 1000);

              },
              error: function (jqXHR, textStatus, errorThrown) {
                var estr = "Page:" + window.location.pathname + ",Function: postDelete()";
                layer.open({
                  title: "错误信息",
                  area: ['600px', '600px'],
                  type: 2,
                  content: "base/error.jhtml?info=" + estr, //
                  btn: ['关闭'] //可以无限个按钮
                });
              }
            });
          } else {
            layer.msg('平台服务费必须小于商品价格');
          }
        })
      } else if (obj.event === 'refuse') {
        layer.prompt({title: '请输入删除原因', formType: 2}, function (text, index) {
          layer.close(index);
          $.ajax({
            url: refuse_url,
            type: "POST",
            data: {
              "id": data.id,
              "code": 1,
              "reason1": text
            },
            dataType: "json",
            success: function (ret) {
              layer.msg(ret.msg, {icon: 6});
              setTimeout(function () {
                window.location.reload();
              }, 1000);
            },
            error: function (jqXHR, textStatus, errorThrown) {
              var estr = "Page:" + window.location.pathname + ",Function: postDelete()";
              layer.open({
                title: "错误信息",
                area: ['600px', '600px'],
                type: 2,
                content: "base/error.jhtml?info=" + estr, //
                btn: ['关闭'] //可以无限个按钮
              });
            }
          });
        });
      } else if (obj.event === 'xiajia') {
        $.ajax({
          url: 'system/goods/downward.json',
          type: "POST",
          data: {
            "id": data.id

          },
          dataType: "json",
          success: function (ret) {
            layer.msg(ret.msg, {icon: 6});
            setTimeout(function () {
              window.location.reload();
            }, 1000);
          },
          error: function (jqXHR, textStatus, errorThrown) {
            var estr = "Page:" + window.location.pathname + ",Function: postDelete()";
            layer.open({
              title: "错误信息",
              area: ['600px', '600px'],
              type: 2,
              content: "base/error.jhtml?info=" + estr, //
              btn: ['关闭'] //可以无限个按钮
            });
          }
        });

      } else if (obj.event === 'shangjia') {
        $.ajax({
          url: 'system/goods/up.json',
          type: "POST",
          data: {
            "id": data.id

          },
          dataType: "json",
          success: function (ret) {
            layer.msg(ret.msg, {icon: 6});
            setTimeout(function () {
              window.location.reload();
            }, 1000);
          },
          error: function (jqXHR, textStatus, errorThrown) {
            var estr = "Page:" + window.location.pathname + ",Function: postDelete()";
            layer.open({
              title: "错误信息",
              area: ['600px', '600px'],
              type: 2,
              content: "base/error.jhtml?info=" + estr, //
              btn: ['关闭'] //可以无限个按钮
            });
          }
        });
      } else if (obj.event === 'reason1') {
        layer.alert(data.reason1)
      } else if (obj.event === 'edit') {
        initUpdate(data);
      } else if (obj.event === 'view') {
        initUpdate1(data);
      }
    });


    //ajax提交删除内容
    window.postDelete = function (id) {
      AjaxCommon.ajax(delete_url, "post", "json", {"id": id}, function (ret) {
        if (ret == null) {
          layer.msg("删除失败", {
            icon: 5
          });
        } else {
          layer.msg("删除成功", {
            icon: 6
          });
          layer.closeAll();
          table.reload('listReload');
        }
        return ret;
      });
    };

    //ajax提交修改内容
    window.postUpdate = function (data) {
      var formData = new FormData();
      formData.append("data", JSON.stringify(data.field));
      // formData.append("file", $("input[name='file']")[0].files[0]);
      $.ajax({
        url: update_url,
        type: "POST",
        //traditional:true,
        data: formData,
        processData: false,
        contentType: false,
        success: function (data) {
          if (data.code == 0) {
            layer.closeAll();
            layer.msg(data.msg, {time: 600, icon: 1}, function () {
              //table.reload('listReload');
              location.replace(location.href);
            });
          } else {
            layer.msg(data.msg, {icon: 5});
          }
        },
        error: function (jqXHR, textStatus, errorThrown) {
          var estr = "Page:" + window.location.pathname + ",Function:postUpdate()";
          layer.open({
            title: "错误信息",
            type: 2,
            content: "base/error.jhtml?info=" + estr,
            btn: ['关闭'] //可以无限个按钮
          });
        }
      });
    }
  });

</script>


</body>

</html>